#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <time.h>


#define ABS(x) (x) < 0 ? -(x) : (x)
#define PAUSE system("pause")
#define DEBUG(string,...) printf("Debug:"#string" "__VA_ARGS__)




int MyUserInputInt()			//Last modified date:2021-01-21 14:10
/**
 * This function will make user enter a long Type and return.
 * when user input illegal,
 * function will automaticly ask user to enter again.
 */
/**
 *tips：注释中会出现以下情形
 * //=======这段代码用于.....=======
 *  {code}
 * //=======这段代码用于.....=======
 * * *
 *每个变量名后面都会有该变量的类型，如整形变量num_i中_i代表这个变量是个整形变量
 */
{
    fflush(stdin);
    int i = -9, j = -9, k = -9, g = -9;    //循环变量，其中变量i用于表示用户输入的数字的位数
    int ReturnNum = -9;                    //返回值
    _Bool IsLegalNumber = 0;         //用于判断用户输入是否为合法数字，默认为否
    _Bool IsNegative = 0;            //用于判断用户输入是否为一个负数

    char chars [12];                       //用户输入的内容会以字符数组的方式暂时储存


//===========================这段代码主要将用户输入的数字储存为字符数组==============================
    i = 0;
    _Bool IsZeroBeforeNumber = 0;
    _Bool IsNeedGetchar = 1;
    char temp_c = '\0';//该字符型变量用于逐个扫描用户输入
    char temp1_c = '\0';
    while(1)
    {
        if (IsNeedGetchar == 1)
        {
            while ((temp1_c = getchar()) == ' ');//过滤用户输入的空格
            temp_c = temp1_c;

            IsNeedGetchar = 0;
        }


        if(IsLegalNumber == 0 && temp_c == '0')//过滤用户输入的0（在数字前的，如00023前的0）
        {
            while ((temp1_c = getchar()) == ' ');
            temp_c = temp1_c;
            IsNeedGetchar = 0;

            if(temp_c == '\n')//如果0后面紧跟'\n'，说明用户想输入一个0
            return 0;

            if(temp_c == '-')
            {
                printf("You only can enter number, no other character!! Try again !!\n");
                break;
            }


            IsZeroBeforeNumber = 1;
            continue;
        }
        IsNeedGetchar = 1;


        if (i == 0 && temp_c == '-')//判断用户输入的数是否为负数
        {
            chars[i] = '-';
            IsNegative = 1;
            i++;
            continue;
        }


        if (temp_c == '\n')//注意这个死循环while(1)的最后有一个break，当跳出这个if结构时会直接跳出死循环
        {
            if(chars[i - 1] == '-')//如果回车符前有一个'-'而不是数字表明用户只输入了一个'-'，将符号视为非法字符报错
                printf("You only can enter number, no other character !! Try again !!\n");
        }
        else if((temp_c == '.' && IsZeroBeforeNumber == 1)  ||
                (temp_c == '.' && i > 0 && IsNegative == 0) ||//这个if用于判断用户是否输入一个小数，是则报错
                (temp_c == '.' && i > 1 && IsNegative == 1))
        {
            while ((temp1_c = getchar()) == ' ');//过滤用户输入的空格
            temp_c = temp1_c;
            IsNeedGetchar = 0;

            if(temp_c == '\n')//如果回车符前有一个'.'而不是数字表明用户只输入了一个'.'，将符号视为非法字符报错
                printf("You only can enter number, no other character !! Try again !!\n");
            else
                printf("Please enter a integer!\n");

            IsLegalNumber = 0;
        }
        else if (temp_c < '0' || temp_c > '9')//这个用于判断用户有没有输入数字以外的字符
        {
            printf("You only can enter number, no other character !! Try again !!\n");
            IsLegalNumber = 0;
        }
        else if (i == 10 && IsNegative == 0)                                                                          //  <————————
        {                                                                                                                   //          |
            printf("Your input seems out the range of long Type (-2147483648 to 2147483647) !! Try again !!\n");            //          |
            IsLegalNumber = 0;                                                                                        //          |
        }                                                                                                                   //          |通过循环变量i初步判断用户输入的
        else if (i == 11 && IsNegative == 1)                                                                          //          |数字位数有没有超过范围（10位）
        {                                                                                                                   //          |
            printf("Your input seems out the range of long Type (-2147483648 to 2147483647) !! Try again !!\n");            //          |
            IsLegalNumber = 0;                                                                                        //          |
        }                                                                                                                   //  <————————
        else
        {
            chars[i] = temp_c;
            IsLegalNumber = 1;
            i++;
            continue;
        }


        break;  //<----break
    }
    if (IsLegalNumber == 0)//如果退出死循环时这个布尔变量为0表明用户输入违法，并重新调用这个函数
    {
        ReturnNum = MyUserInputInt();
        return ReturnNum;
    }//如果这个程序没有进入这个if结构表明初步判断用户输入合法（即当前输入不超过十位数，之后还需验证用户输入是否超过整型变量的取值范围）

//===========================这段代码主要将用户输入的数字储存为字符数组==============================//



//===========================这段代码主要是将chars转换为数字=======================

        if (IsNegative == 1)//这个if结构用于在用户输入是负数时，将chars中每个元素前移消除字符'-'，方便之后的处理（如“-123456”变为“123456”）
        {
            for (j = 0; j < 11; j++)
                chars[j] = chars[j + 1];

            i--;
        }

        int Pow_i = -9;
        g = i;
        ReturnNum = 0;
        for(j = 0; j < i; j++)//这个for循环可以将字符数组chars初步转化为整型数字（这个数字永远为正数，因为chars中存在'-'时会被消除）然后将这个数字赋给ReturnNum
        {
            Pow_i = 1;

            for (k = 0; k < g - 1; k++)//这个for循环相当于math.h中的pow
                Pow_i = Pow_i * 10;

            ReturnNum = ReturnNum + (chars[j] - 48) * Pow_i;
            g--;
        }

        if (IsNegative == 1)//如果用户输入为负数，在这个if之前ReturnNum为正数，将其转换为负数
            ReturnNum = 0 - ReturnNum;

//===========================这段代码主要是将chars转换为数字=======================



//======================这段代码主要用于确认ReturnNum是否等于chars中表示的数字================（如果不是，一般表明用户输入的数字超出范围）
//实现方法：将ReturnNum中的每一位取出与chars中的元素作对比
    int NumCheck_i = ReturnNum;
    int temp_i = -9;//temp用于储存取出的ReturnNum的最后一位

    for (j = 0; j < i; j++)
    {
        temp_i = NumCheck_i % 10;		//取出数字的最后一位
        NumCheck_i = NumCheck_i / 10;	//去掉数字的最后一位

        if(IsNegative == 1)
            temp_i = 0 - temp_i;

        if (temp_i != (chars[i - 1 - j] - 48))		//将数字的最后一位与数组chars中对应的元素比较
            {
                IsLegalNumber = 0;
                printf("Your input seems out the range of long Type (-2147483648 to 2147483647) !! Try again !!\n");
                break;
            }
    }
//======================这段代码主要用于确认ReturnNum是否等于chars中表示的数字================

    if (IsLegalNumber == 0)//当用户输入不合法时重新调用函数
    {
        ReturnNum = MyUserInputInt();
    }
    return ReturnNum;
}

//======================================================================

void MyStrcat(_Bool doNumToStr, long num, char *target, const char *string)       //Last modefied date:2021-03-06 23:51
/**
 * This function can converts the incoming interger number into a string if you need
 * and add the converted string to the end of this array.
 * 
 * The first parameter tells the function whether it needs to insert a number into the string
 * The second parameter is the number you want to convert
 * The third parameter is the string you want to add
 * The forth parameter is the address of the target.
 * 
 * if(doNumToStr == 1 && *string == '1')this function will turn to copy mode.
 * if(doNumToStr == 0 && num == 1)      this function will turn to copy mode.
 */
{
    int i, j;
    
    if(! ((doNumToStr == 0 && num == 1) || (doNumToStr == 1 && *string == '1')))
    {
        //printf("Debug:in\n");
        for(j = 0;*(target + j) != '\0';j++);
        target = target + j;
    }

    if(doNumToStr == 1)
    {
        if(num == 0)
        {
            *target = '0';
            *(target + 1) = '\0';
            return ;
        }

        int k;
        char temp;

        for(i = 0; num > 0; i++)
        {
            *(target + i) = num % 10 + 48;
            num = num / 10;
        }

        for(k = 0; k < i / 2; k++)
        {
            temp = *(target + k);
            *(target + k) = *(target + i - k - 1);
            *(target + i - k - 1) = temp;
        }
    }
    else
    {
        for(i = 0;*(string + i) != '\0'; i++)
        {
            *(target + i) = *(string + i);
        }
    }

    *(target + i) = '\0';
}

//======================================================================

void MyStrcpy(char *target, const char *string)      //Last modefied date:2021-03-10 22:26
{
    int i;
    for(i = 0;*(string + i) != '\0'; i++)
        {
            *(target + i) = *(string + i);
        }
    *(target + i) = '\0';
}

//======================================================================

double MyPower(double x,long long n)          //Last modefied date:2021-04-22 20:38
{
    if(n == 0 || x == 1)
        return 1;
    if(x == 0)
        return 0;

    _Bool isNegative = 0;
    if(n < 0)
    {
        isNegative = 1;
        n = -n;
    }
    double returnNum = 1;
    if(0 == (n&1))
    {
        returnNum = MyPower(x * x, n/2);
    }
    else
    {
        returnNum = MyPower(x * x, n/2) * x;
    }

    if(isNegative == 0)
        return returnNum;
    else
        return 1 / returnNum;
}

//======================================================================

int MyStrIntoInt(const char *string)            //Last modefied date:2021-06-15 19:40
{
    int returnNum = 0;
    for(; *string != '\0'; string++)
    {
        returnNum = returnNum * 10 + (*string - 48);
    }

    return returnNum;
}

//======================================================================

int MyStrcmp(const char *target, const char *string)        //Last modefied date:2021-03-11 12:07
{
    int i;
    for(i = 0; ; i++)
    {
        if(*(target + i) == '\0' && *(string + i) == '\0')
            return 0;
        else if(*(target + i) < *(string + i) || *(target + i) == '\0')
            return 1;
        else if(*(target + i) > *(string + i) || *(string + i) == '\0')
            return -1;
    }
}

//======================================================================

int MyStrlen(const char *string)
{
    int i;
    for(i = 1; *string != '\0'; i++,string++);
        return i;
}

//======================================================================

void MyGets(const int n, char *target)          //Last modefied date:2021-03-11 16:58
/**
 * This function will ask user to enter a string
 * and copy the string to target char array.
 * if user enter over n characters, function will ask user enter again.
 * 
 * The first parameter is the biggest length of the string
 * The second parameter is the target array.
 */
{
    int i;
    char chs[n + 1];
    for(i = 0; i < n + 1; i++)
    {
        if((chs[i] = getchar()) == '\n')
        {
            if(i == 0)
            {
                fflush(stdin);
                MyGets(n, target);
                return ;
            }

            int k = i;
            for(i = 0; i < k; i++)
                *(target + i) = chs[i];
            *(target + i) = '\0';
            return ;
        }
    }
    printf("You only can input %d characters.\n",n);
    fflush(stdin);
    MyGets(n, target);
}

//======================================================================

void MySetConsoleSize(int cols, int lines)     //Last modefied date:2021-03-07 09:39
{
    char chs[50] = "mode con cols=";
    MyStrcat(1, cols, chs, "0");
    MyStrcat(0, 0, chs, " lines=");
    MyStrcat(1, lines, chs, "0");
    system(chs);
}

//======================================================================

void MyNumberSystemConversion(unsigned long long converNum, int numSystem, char *target)    //Last modefied date:2021-06-16 16:58
/**
 * This function will convert an incoming number to a string in the specified number system,
 * you need an character array to receive it.
 * 
 * The first parameter is the number you want to convert,
 * The second parameter is the numbersystem you want convert to,
 * the third parameter is the array used to receive string.
 */
{
    if(numSystem < 2 || numSystem > 36)
    {
        printf("Error:parameter numSystem only can be 2 ~ 36.\n");
        return;
    }


    char temp[64];      //Temporarily holds a character, then copies it into the target array.
    int i = 0;          //array index, use to copy character to the corresponding position in the array.
    do{
        
        temp[i] = converNum % numSystem;    //Take the lowest order
        if(temp[i] >= 10)
            temp[i] += 55;       //convert the lowest order to a character
        else 
            temp[i] += 48;       //convert the lowest order to a character
        //DEBUG(%d  %c\n,,temp[i], temp[i]);
        converNum /= numSystem;     //remove the lowest order.
        i++;
    }while(converNum > 0);
    i--;

    for(; i >= 0; i--, target++)    //copy array temp to receive string.
        *target = temp[i];
    *target = '\0';
}

//======================================================================

double Myabs(double num)
{
    if(num < 0)
        num = -num;
    return num;
}

//***************************************************************************

void MyShowOrHideCursor(_Bool TorF)
{
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &(CONSOLE_CURSOR_INFO){1, TorF});
}

//======================================================================

void MyGotoxy(int x, int y)
{
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), (COORD){x,y});
}

//======================================================================

COORD MyGetCursorPosition()
{
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
    return (COORD){csbi.dwCursorPosition.X, csbi.dwCursorPosition.Y};
}

int MyHorizontalSelector(short gap, short options, short preselection)
/**
 * gap is the distance from a pointer to another pointer
 * 
 * options is the number of the options you have set
 * 
 * need <stdio.h> <stdlib.h> <windows.h>
 */
{
    if(options < 2)
    {
        printf("Selector error, parameter options can't smaller than two!!\n");
        return 0;
    }
    if(preselection < 1 || preselection > options)
    {
        printf("Selector error, parameter preselection can't smaller than zero or bigger than options!!\n");
        return 0;
    }
    if(gap < 0)
    {
        printf("Selector error, parameter gap can't smaller than zero!!\n");
        return 0;
    }
    
    int initial_X = MyGetCursorPosition().X;
    int initial_Y = MyGetCursorPosition().Y;
    printf("%d %d\n",initial_X, initial_Y);

    int returnNum = preselection;
    gap++;

    void Show()
    {
        //printf("Debug: returnNum == %d",returnNum);

        int k;
            MyGotoxy(initial_X, initial_Y);
            for(k = 0; k < gap * options; k++)
            {
                if(k == gap * (returnNum - 1))
                    printf("@");
                else
                    printf(" ");
            }
        printf("\n\n");
        printf("Press 'A' or 'D' to select, Press |enter| to confirm, Press |esc| to back.\n");
    }

    Show();
    while(1)
    {
        char ch = getch();
        if(ch == 'A' || ch == 'a')
        {
            returnNum--;
            if(returnNum < 1)
                returnNum = 1;
        }
        else if(ch == 'D' || ch == 'd')
        {
            returnNum++;
            if(returnNum > options)
                returnNum = options;
        }
        else if(ch == 13)
            return returnNum;
        else if(ch == 27)
            return 0;
        
        Show();
    }
}

//======================================================================

void MyEraser(int initial_X, int initial_Y, int length, int high)
{
    MyGotoxy(initial_X, initial_Y);
    int i, k;
    for(i = 0; i < high; i++)
    {
        for(k = 0; k < length; k++)
        {
            printf(" ");
        }
        printf("\n");
    }
    MyGotoxy(initial_X, initial_Y);
}

//***************************************************************************

int BinarySearch(const int* arr, const int arrLength, int target)
{
    int leftBoundary = 0;
    int rightBoundary = arrLength - 1;
    int mid = 0;
    while(leftBoundary <= rightBoundary)
    {
        mid = leftBoundary + (rightBoundary - leftBoundary) / 2;
        if(arr[mid] == target)
            return mid;
        else if(arr[mid] < target)
            leftBoundary = mid + 1;
        else
            rightBoundary = mid - 1;
    }
    return -1;
}

//***************************************************************************

unsigned long long MyuHEXstringToUll(const char* string)
//This function will convert incoming HEXstring to unsigned long long.
{
    int i = 0;
    char temp;
    unsigned long long returnNum = 0;
    do{
        temp = *string;
        returnNum <<= 4;

        if(temp >= '0' && temp <= '9')
            returnNum += temp - '0';
        else if(temp >= 'a' && temp <= 'f')
            returnNum += temp - 'a' + 10;
        else if(temp >= 'A' && temp <= 'F')
            returnNum += temp - 'A' + 10;
        else
        {
            printf("Error:incoming string is not a HEX string.\n");
            return 0;
        }

        i++;
        string++;
    }while(*string != '\0' && i < 16);

    if(i <= 16)
        return returnNum;
    else
    {
        printf("Error:incoming string out of range.\n");
        return 0;
    }
}

//==============================

void MyEncryptString_mode1(const char *string, char *target)
{
    srand(time(NULL));

    int strLength = 0;
    const char *temp = string;
    for(; *temp != '\0'; strLength++, temp++);  //Get length of string.
    if(strLength > 6)
    {
        printf("Error:string length can not over 6.\n");
        return;
    }

    char *startOftarget = target;
    for(int i = 0; i < 16; i++)     
        startOftarget[i] = -1;

    
    *target = (rand() % 25) * 10 + strLength;
    target++;

    int key = rand() % 10;
    *target = (rand() % 25) * 10 + key;
    target++;

    int startPosition = rand() % 3 + 1;//1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
    *target = (rand() % 25) * 10 + startPosition;
    target += startPosition;

    for(int j = 1; j <= strLength; j++)
    {
        *target = *string + j * key;
        string++;
        target += 2;
    }

    for(int j = 0; j < 16; j++)
    {
        if(startOftarget[j] == -1)
        startOftarget[j] = rand() % 256;
    }

    startOftarget[16] = '\0';
}


void MyUncryptString_mode1(const char *string, char *target)
{
    int strLength = (unsigned)(*string++) % 10;
    int key = (unsigned)(*string++) % 10;
    string += (unsigned)(*string) % 10;

    for(int j = 1; j <= strLength; j++)
    {
        *target = *string - j * key;
        string += 2;
        target++;
    }
    *target = '\0';
}

//==============================

void MyImplicitInput(const int lengthLimit, char *target)
{
    MyShowOrHideCursor(0);
    const int HIDE = 0;
    const int EXPOSE = 1;
    const int TWINKLE = 2;
    int outputStringLength = 0;
    int exposeTime = 0;
    char outputString[lengthLimit];
    int initial_X = MyGetCursorPosition().X;
    int initial_Y = MyGetCursorPosition().Y;
    int i;
    for(i = 0; i < lengthLimit; i++)
        outputString[i] = -1;
    for(i = 0; i < lengthLimit + 1; i++)
        printf(" ");
    printf("Hold |Tab| to preview.");


    void Show(int mode)
    {
        MyGotoxy(initial_X,initial_Y);
        if(mode == EXPOSE)
            for(int j = 0; j < outputStringLength; j++)
                printf("%c",outputString[j]);
        else if(mode == HIDE)
            for(int j = 0; j < lengthLimit; j++)
            {
                if(outputString[j] == -1)
                    printf(" ");
                else
                    printf("*");
            }
        else if(mode == TWINKLE){
            for(int j = 0; j < outputStringLength; j++)
                printf(" ");
            Sleep(100);
            Show(HIDE);
            Sleep(100);
            MyGotoxy(initial_X,initial_Y);
            for(int j = 0; j < outputStringLength; j++)
                printf(" ");
            Sleep(100);
        }
        
    }

    while(1)
    {
        if(exposeTime > 0)
        {
            exposeTime--;
            Show(EXPOSE);
            Sleep(500);
        }else{
            Show(HIDE);
        }

        if(kbhit())
        {
            char inputChar = getch();
            exposeTime = 0;
            switch(inputChar)
            {
                case 13://enter key
                    goto outWhile;
                    break;
                case 8://backspace key
                    if(outputStringLength > 0)
                    {
                        outputStringLength--;
                        outputString[outputStringLength] = -1;
                    }
                    break;
                case 9://tab key
                    exposeTime = 1;
                    break;
                default:
                    if(outputStringLength == lengthLimit)
                        Show(TWINKLE);
                    else if(inputChar >= 32 && inputChar <= 126)
                    {
                        outputString[outputStringLength] = inputChar;
                        outputStringLength++;
                    }
                    break;
            }
        }
    }

    outWhile:
    {
        for(i = 0; i < outputStringLength; i++)
            target[i] = outputString[i];
        target[i] = '\0';
    }
    
    putchar('\n');
    MyShowOrHideCursor(1);
}

//==============================

void My_InputAndVerifyPassword(const int lengthLimit, const char *password)
{
    char inputPassword[lengthLimit + 1];
    printf("Password:");
    while(1)
    {
        MyImplicitInput(lengthLimit, inputPassword);
        if(!MyStrcmp(password, inputPassword))
            break;
        else
            printf("Incorrect password!\n");
    }
}

void My_InputAndSetPassword(const int lengthLimit, char *target)
{
    char reConfirmPassword[lengthLimit + 1];
    while(1)
    {
        printf("Password:");
        MyImplicitInput(lengthLimit,target);
        printf("reConfirmPassword:");
        MyImplicitInput(lengthLimit, reConfirmPassword);
        if(!MyStrcmp(target, reConfirmPassword))
            break;
        else
            printf("The two input passwords are different!\n");
    }
}

void My_EncryptedPasswordToFile(FILE *fp, const char *encryptedPassword)
{
    unsigned long long *ULLptr = (unsigned long long *)encryptedPassword;
    unsigned long long ULlong1 = *ULLptr;
    ULLptr = (unsigned long long *)(encryptedPassword + 8);
    unsigned long long ULlong2 = *ULLptr;
    char outputString[99];
    char *outputString_temp = outputString;
    MyNumberSystemConversion(ULlong1, 16, outputString_temp);
    for(; *outputString_temp != '\0'; outputString_temp++);
    MyNumberSystemConversion(ULlong2, 16, outputString_temp);
    fprintf(fp,"%s\n",outputString);
}

void My_EncryptedPasswordFromFile(FILE *fp, char *target)
{
    char HEXstring[17];
    int i;
    for(i = 0; i < 16; i++)
    {
        HEXstring[i] = getc(fp);
    }
    HEXstring[i] = '\0';
    unsigned long long ULlong1 = MyuHEXstringToUll(HEXstring);

    for(i = 0; i < 16; i++)
    {
        HEXstring[i] = getc(fp);
        //printf("Debug:%d\n",HEXstring[i]);
    }
    HEXstring[i] = '\0';
    unsigned long long ULlong2 = MyuHEXstringToUll(HEXstring);
    unsigned long long *_target = (unsigned long long *)target;
    *_target++ = ULlong1;
    *_target = ULlong2;
}

void My_CreateAccount(FILE *fp)
{
    char inputPassword[21];
    char inputUsername[21];
    printf("Username:");
    MyGets(20, inputUsername);
    My_InputAndSetPassword(6, inputPassword);
    
    char encryptedPassword [17];
    MyEncryptString_mode1(inputPassword, encryptedPassword);
    fprintf(fp,"%s\n",inputUsername);
    My_EncryptedPasswordToFile(fp, encryptedPassword);
}

void MyLoginSystem()
{
    FILE *fp = fopen("USNAPSW", "r");
    if(!fp)
    {
        const char defaultUsername[6] = "admin";
        const char encryptedDefaultPassword[17] = {85,182,112,91,99,84,104,9,115,126,113,19,120,105,86,51,0};
        printf("There is no administrator account currently, please login with default account.\n");

        char uncryptedPassword[7];
        char inputPassword[21];
        char inputUsername[21];
        MyUncryptString_mode1(encryptedDefaultPassword, uncryptedPassword);
        printf("Username:%s\n",defaultUsername);
        My_InputAndVerifyPassword(20, uncryptedPassword);

        printf("Now create a new account, please enter your:\n");
        My_CreateAccount(fopen("USNAPSW", "w"));
        printf("Account created successfully, Please restart the program.\n");
        system("pause");
        exit(0);
    }else{
        const char username[21];
        fscanf(fp, "%s", username);
        printf("%s Welcome!\n",username);
        
        char encrytpedPassword[17];
        char uncrytpedPassword[7];
        fseek(fp, 2L, SEEK_CUR);
        My_EncryptedPasswordFromFile(fp, encrytpedPassword);
        MyUncryptString_mode1(encrytpedPassword, uncrytpedPassword);
        My_InputAndVerifyPassword(20, uncrytpedPassword);
        printf("Login successfully!\n");
        printf("press enter to continue, if you want to change account, press backspace.\n");
        char select = getch();
        while(select != 13 && select != 8)
        {
            printf("What's this??\n");
            select = getch();
        }
        if(select == 13)
            return;
        else My_CreateAccount(fopen("USNAPSW", "w"));
        printf("Account changed successfully.\n");
        system("pause");
        system("pause");
    }

    fclose(fp);
    return ;
}

//======================================================================

//void MyNumberConversion(long long )

//======================================================================






